let vm = new Vue({
    el:'#app',  //选中整个main
    data:{
        meeting:{},//初始化对象     vue建议声明对象同时进行初始化，避免undefinded
        needJoinCount:'',
        joinedMeetingCount:'',
        isNeed:false,
        uid:'',
        isJoin:false
    },
    methods:{
        //获取需要参加会议人数
        getNeedJoinCount:function () {
            axios.get(`meeting/needJoinCount/${this.meeting.id}`).then(rs=>{
                this.needJoinCount=rs.data.obj;
            });
        },
        //获取已经参与了会议的人数
        getjoinedMeetingCount:function () {
            axios.get(`meeting/joinedMeetingCount/${this.meeting.id}`).then(rs=>{
                this.joinedMeetingCount=rs.data.obj;
            });
        },
        //判断用户是否已经参加会议
        isJoinMeeting:function () {
            axios.get(`meeting/isJoinMeeting/${this.uid}/${this.meeting.id}`).then(rs=>{
                if (rs.data.obj!=0){
                    this.isJoin=true;
                }
            })
        },
        //判断当前用户是否需要参与会议
        isNeedJoin:function () {
            // debugger;
            let makeUser = this.meeting.makeUser;
            let split = makeUser.split(",");
            let id = JSON.parse(sessionStorage.getItem("user")).id;
            this.uid = id;
            // console.log(split.indexOf(id+''))
            if (split.indexOf(id+'')!=-1){//证明需要参与会议
                this.isNeed=true;
                this.isJoinMeeting();
            }
        },
        //参与会议
        joinMeeting:function () {
            axios.post(`meeting/joinMeeting/${this.uid}/${this.meeting.id}`).then(rs=>{
               layer.msg("参与会议成功！");
               this.isJoin=true;
            });
        },
        //取消参与会议
        cancelMeeting:function () {
            axios.put(`meeting/cancelMeeting/${this.uid}/${this.meeting.id}`).then(rs=>{
                layer.msg("取消参加会议成功！");
                this.isJoin=false;
            });
        }
    },
    created:function () {
        this.meeting = parent.layer.obj;
        this.getNeedJoinCount();
        this.getjoinedMeetingCount();
        this.isNeedJoin();
    }
});